Skip to content

feat: add load_view to REST catalog#3224

Open
spr0els wants to merge 3 commits intoapache:mainfrom
spr0els:load_view
Open

feat: add load_view to REST catalog#3224
spr0els wants to merge 3 commits intoapache:mainfrom
spr0els:load_view

Conversation

@spr0els
Copy link
Copy Markdown

@spr0els spr0els commented Apr 9, 2026

Rationale for this change

This is part of #818 and implements the load_view method for REST catalogs.

Are these changes tested?

Unit tests are added for:

  • successful loading of a view
  • thrown 404 error when trying to load a non existing view

Are there any user-facing changes?

This adds the load_view method for REST catalogs

Comment thread pyiceberg/catalog/__init__.py Outdated
Comment on lines +651 to +652
You can also use this method to check for view existence using 'try catalog.load_view() except NoSuchViewError'.
Note: This method doesn't scan data stored in the view.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I would say we remove these.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the docstring

assert actual == expected


def test_load_view_404(rest_mock: Mocker) -> None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would also add a test that should return a view does not exists when trying to load a table with loadView

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I'm wrong, but isn't this case already covered with the test_load_view_404 test?
If no view with the same identifier as the table identifier is found in the warehouse, this would be the same case as loading a non existent view.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is implementation dependent on the server, so this is an edge case to return the correct exception

But the test is better placed in integration tests rather than mocking

Would be cool to also add integration tests to the test_catalog.py

Comment thread pyiceberg/catalog/__init__.py Outdated
Comment on lines +651 to +652
You can also use this method to check for view existence using 'try catalog.load_view() except NoSuchViewError'.
Note: This method doesn't scan data stored in the view.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread pyiceberg/catalog/rest/__init__.py Outdated
self._check_endpoint(Capability.V1_LOAD_VIEW)
response = self._session.get(
self.url(Endpoints.load_view, prefixed=True, **self._split_identifier_for_path(identifier, IdentifierKind.VIEW)),
params={},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitty: we don't need to pass in the empty params

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the empty params

@spr0els spr0els requested a review from geruh April 16, 2026 09:14
Copy link
Copy Markdown
Contributor

@gabeiglio gabeiglio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from adding integration tests LGTM

@geruh
Copy link
Copy Markdown
Member

geruh commented Apr 16, 2026

I think we just need a rebase here, and I agree with @gabeiglio on adding an integ test if tck has the view support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants